import { http, Method } from "@/utils/request.js";

// 创建微信支付订单
export function createWechatOrder(orderId, data) {
  return http.request({
    url: `/orders/${orderId}/wechatpay`,
    method: Method.POST,
    data
  });
}

// 查询微信支付订单
export function queryWechatOrder(outTradeNo) {
  return http.request({
    url: `/orders/wechatpay/query/${outTradeNo}`,
    method: Method.GET
  });
}

// 关闭微信支付订单
export function closeWechatOrder(outTradeNo) {
  return http.request({
    url: `/orders/wechatpay/close/${outTradeNo}`,
    method: Method.POST
  });
}

// 申请退款
export function refundWechatOrder(orderId, reason) {
  return http.request({
    url: `/orders/${orderId}/refund`,
    method: Method.POST,
    data: { reason }
  });
}

// 查询退款状态
export function queryWechatRefund(outRefundNo) {
  return http.request({
    url: `/orders/refund/query/${outRefundNo}`,
    method: Method.GET
  });
}

// 微信企业付款到零钱
export function wechatTransferToBalance(data) {
  return http.request({
    url: '/wechat/transfer/balance',
    method: Method.POST,
    data
  });
}

// 查询微信企业付款状态
export function queryWechatTransfer(outBatchNo) {
  return http.request({
    url: `/wechat/transfer/query/${outBatchNo}`,
    method: Method.GET
  });
}

// 查询微信企业付款明细
export function queryWechatTransferDetail(outBatchNo, outDetailNo) {
  return http.request({
    url: `/wechat/transfer/detail/${outBatchNo}/${outDetailNo}`,
    method: Method.GET
  });
}